﻿@model PrjAssessModels.BaseModels.Project

@section scripts{
        <script type="text/javascript">
            $(document).ready(function ()
            {
                var viewModelJs = '@Html.Raw(Newtonsoft.Json.JsonConvert.SerializeObject(this.Model))';
                var viewModel = ko.mapping.fromJSON(viewModelJs);
                viewModel.PrjExtent.WorkRatio = ko.computed(function ()
                {
                    try
                    {
                        return parseFloat(this.SupportNo()) + parseFloat(this.EnviComplicate()) + parseFloat(this.OperateMethod());
                    }
                    catch(e)
                    {
                        return 0;
                    }
                }, viewModel.PrjExtent);

                viewModel.PrjExtent.PrjRatio = ko.computed(function () {
                    try {
                        return parseFloat(this.RegionRatio()) * parseFloat(this.ComplicateRatio()) * parseFloat(this.SurveyTypeRatio()) * parseFloat(this.TeamRatio()) * parseFloat(this.ScaleRatio());
                    }
                    catch (e) {
                        return 0;
                    }
                }, viewModel.PrjExtent);


                ko.applyBindings(viewModel);

 

           
                function SubmitForm(TargetUrl)
                {
                 
                    $('#myForm').unbind('submit');
                    $('#myForm').submit(function (event)
                    {

                        event.preventDefault();
                        var jsonData = ko.toJSON(viewModel);
                        var url = '@Url.Action("SaveAssess","ReadAssess")';
                        $.post(url, { 'prjJson': jsonData },
                            function (data)
                            {
                                if (data = 1)
                                {
                                    document.location.href = TargetUrl;//
                                }
                                else
                                {
                                    alert('Err!');

                                }
                            });
                        return false;

                    }
                    );
                }
                //默认就去第二页
                SubmitForm('@Url.Action("DisplayMertialBury","ReadAssess")');
              
                $('#next').click(function (event)
                {
                    event.preventDefault();
                    var url = '@Url.Action("DisplayMertialBury","ReadAssess")';
                    SubmitForm(url);
                    $('#submit').trigger('click');
                }
                );
                $('#next2').click(function (event)
                {
                    event.preventDefault();
                    var array = viewModel.MaterialBurys();
                    if (array.length > 0)
                    {
                        var url = '@Url.Action("DisplayWorks","ReadAssess")';
                        SubmitForm(url);
                        $('#submit').trigger('click');
                    }
                }
               );

                  })
        </script>
}
<br />
<div class="container">
    <ol class="breadcrumb">
        <li class="active">1.填写项目基本信息</li>
        <li id="next"><a href="#">2.填写项目材料埋设明细</a></li>
        <li><a href="#" id="next2">3.填写项目工作量明细</a></li>
    </ol>
    @using (Html.BeginForm("SaveAssess", "ReadAssess", FormMethod.Post, new { id="myForm" , enctype = "multipart/form-data", @class = "form-horizontal" }))
    {
        <fieldset>
            <legend>基本信息</legend>
            <div class="form-group">
                @Html.LabelFor(m => m.PrjName, new { @class = "col-lg-2 control-label" })
                <div class="col-lg-10">

                    @Html.TextBoxFor(m => m.PrjName, new { @class = "form-control",data_bind="value: PrjName", placeholder = "工程名称", required = "" })
                </div>
            </div>
            <div class="form-group">
                @Html.LabelFor(m => m.PrjId, new { @class = "col-lg-2 control-label" })
                <div class="col-lg-10">
                    @Html.TextBoxFor(m => m.PrjId, new {data_bind="value: PrjId", @class = "form-control", placeholder = "工程编号", required = "" })
                </div>
            </div>
            <div class="form-group">
                @Html.LabelFor(m => m.Contract, new { @class = "col-lg-2 control-label" })
                <div class="col-lg-10">
                    @Html.TextBoxFor(m => m.Contract, new {data_bind="value: Contract", @class = "form-control", placeholder = "合同额", type = "number", required = "", step = "any" })
                </div>
            </div>
            <div class="form-group">
                @Html.LabelFor(m => m.Address, new { @class = "col-lg-2 control-label" })
                <div class="col-lg-10">
                    @Html.TextBoxFor(m => m.Address, new {data_bind="value: Address", @class = "form-control", placeholder = "地址", required = "" })
                </div>
            </div>
            <div class="form-group">
                @Html.LabelFor(m => m.Manager, new { @class = "col-lg-2 control-label" })
                <div class="col-lg-10">
                    @Html.TextBoxFor(m => m.Manager, new {data_bind="value: Manager", @class = "form-control", placeholder = "项目经理", required = "" })
                </div>
            </div>
            <div class="form-group">
                @Html.LabelFor(m => m.Leader, new { @class = "col-lg-2 control-label" })
                <div class="col-lg-10">
                    @Html.TextBoxFor(m => m.Leader, new {data_bind="value: Leader", @class = "form-control", placeholder = "班组长", required = "" })
                </div>
            </div>
            <div class="form-group">
                @Html.LabelFor(m => m.Manufacture, new { @class = "col-lg-2 control-label" })
                <div class="col-lg-10">
                    @Html.TextBoxFor(m => m.Manufacture, new {data_bind="value: Manufacture", @class = "form-control", placeholder = "采购厂商", required = "" })
                </div>
            </div>
            <div class="form-group">
                @Html.LabelFor(m => m.MonitorType, new { @class = "col-lg-2 control-label" })
                <div class="col-lg-10">
                    @Html.TextBoxFor(m => m.MonitorType, new {data_bind="value: MonitorType",  @class = "form-control", placeholder = "监测类型", required = "" })
                </div>
            </div>
            <div class="form-group">
                @Html.LabelFor(m => m.SurveyNo, new { @class = "col-lg-2 control-label text-danger" })
                <div class="col-lg-10">
                    @Html.TextBoxFor(m => m.SurveyNo, new { data_bind="value: SurveyNo", @class = "form-control", placeholder = "监测次数", type = "number", step = "any", required = "" })
                </div>
            </div>
            <div class="form-group">
                @Html.LabelFor(m => m.ConstructionPeriod, new { @class = "col-lg-2 control-label" })
                <div class="col-lg-10">
                    @Html.TextBoxFor(m => m.ConstructionPeriod, new {data_bind="value: ConstructionPeriod", @class = "form-control", placeholder = "工期", type = "number", step = "any", required = "" })
                </div>
            </div>

            <div class="form-group">
                @Html.LabelFor(m => m.MaterialSum, new { @class = "col-lg-2 control-label" })
                <div class="col-lg-10">
                    @Html.TextBoxFor(m => m.MaterialSum, new { @class = "form-control", placeholder = "材料费用", @readonly = "readonly", type = "number", step = "any", required = "" })
                </div>
            </div>
            <div class="form-group">
                @Html.LabelFor(m => m.BurySum, new { @class = "col-lg-2 control-label" })
                <div class="col-lg-10">
                    @Html.TextBoxFor(m => m.BurySum, new { @class = "form-control", placeholder = "埋设费用", @readonly="readonly", type = "number", step = "any", required = "" })
                </div>
            </div>
            <div class="form-group">
                @Html.LabelFor(m => m.MaterialBurySum, new { @class = "col-lg-2 control-label" })
                <div class="col-lg-10">
                    @Html.TextBoxFor(m => m.MaterialBurySum, new { @class = "form-control", placeholder = "材料埋设费用", @readonly = "readonly", type = "number", step = "any", required = "" })
                </div>
            </div>
            <div class="form-group">
                @Html.LabelFor(m => m.WorkSum, new { @class = "col-lg-2 control-label" })
                <div class="col-lg-10">
                    @Html.TextBoxFor(m => m.WorkSum, new { @class = "form-control", placeholder = "核定工作量", @readonly = "readonly", type = "number", step = "any", required = "" })
                </div>
            </div>
        </fieldset>
        <fieldset data-bind="with: PrjExtent">
            <legend>基坑工作量系数</legend>
            <div class="form-group">
                @Html.LabelFor(m => m.PrjExtent.WorkRatio, new { @class = "col-lg-2 control-label text-info" })
                <div class="col-lg-10" >
                    @Html.TextBoxFor(m => m.PrjExtent.WorkRatio, new { @class = "form-control", data_bind="value: WorkRatio", placeholder = "基坑工作量系数", type = "number", required = "", step = "any", @readonly = "readonly" })
                </div>
            </div>
            <div class="form-group">
                @Html.LabelFor(m => m.PrjExtent.SupportNo, new { @class = "col-lg-2 control-label" })
                <div class="col-lg-10" >
                    @Html.TextBoxFor(m => m.PrjExtent.SupportNo, new { @class = "form-control", data_bind="value: SupportNo",placeholder = "支撑层数", type = "number", step = "any", required = "" })
                </div>
            </div>
            <div class="form-group">
                @Html.LabelFor(m => m.PrjExtent.EnviComplicate, new { @class = "col-lg-2 control-label" })
                <div class="col-lg-10">
                    @Html.TextBoxFor(m => m.PrjExtent.EnviComplicate, new { @class = "form-control",data_bind="value: EnviComplicate", placeholder = "环境复杂度", type = "number", step = "any", required = "" })
                </div>
            </div>
            <div class="form-group">
                @Html.LabelFor(m => m.PrjExtent.OperateMethod, new { @class = "col-lg-2 control-label" })
                <div class="col-lg-10">
                    @Html.TextBoxFor(m => m.PrjExtent.OperateMethod, new { @class = "form-control", data_bind="value: OperateMethod",placeholder = "施作方式", type = "number", step = "any", required = "" })
                </div>
            </div>

        </fieldset>
        <fieldset data-bind="with: PrjExtent">
            @Html.HiddenFor(item => item.PrjExtent.PrjId)
            <legend>工程综合系数</legend>
            <div class="form-group">
                @Html.LabelFor(m => m.PrjExtent.PrjRatio, new { @class = "col-lg-2 control-label text-info" })
                <div class="col-lg-10">
                    @Html.TextBoxFor(m => m.PrjExtent.PrjRatio, new { @class = "form-control", data_bind="value: PrjRatio", placeholder = "工程综合系数", type = "number", required = "", step = "any", @readonly = "readonly" })
                </div>
            </div>

            <div class="form-group">
                @Html.LabelFor(m => m.PrjExtent.RegionRatio, new { @class = "col-lg-2 control-label" })
                <div class="col-lg-10">
                    @Html.TextBoxFor(m => m.PrjExtent.RegionRatio, new { @class = "form-control",data_bind="value: RegionRatio", placeholder = "地域系数", type = "number", step = "any", required = "" })
                </div>
            </div>

            <div class="form-group">
                @Html.LabelFor(m => m.PrjExtent.ComplicateRatio, new { @class = "col-lg-2 control-label" })
                <div class="col-lg-10">
                    @Html.TextBoxFor(m => m.PrjExtent.ComplicateRatio, new { @class = "form-control",data_bind="value: ComplicateRatio", placeholder = "复杂系数", type = "number", step = "any", required = "" })
                </div>
            </div>


            <div class="form-group">
                @Html.LabelFor(m => m.PrjExtent.SurveyTypeRatio, new { @class = "col-lg-2 control-label" })
                <div class="col-lg-10">
                    @Html.TextBoxFor(m => m.PrjExtent.SurveyTypeRatio, new { @class = "form-control",data_bind="value: SurveyTypeRatio", placeholder = "监测类型系数", type = "number", step = "any", required = "" })
                </div>
            </div>

            <div class="form-group">
                @Html.LabelFor(m => m.PrjExtent.TeamRatio, new { @class = "col-lg-2 control-label" })
                <div class="col-lg-10">
                    @Html.TextBoxFor(m => m.PrjExtent.TeamRatio, new { @class = "form-control", data_bind="value: TeamRatio",placeholder = "班组折减率", type = "number", step = "any", required = "" })
                </div>
            </div>

            <div class="form-group">
                @Html.LabelFor(m => m.PrjExtent.ScaleRatio, new { @class = "col-lg-2 control-label" })
                <div class="col-lg-10">
                    @Html.TextBoxFor(m => m.PrjExtent.ScaleRatio, new { @class = "form-control", data_bind="value: ScaleRatio",placeholder = "规模效应折减", type = "number", step = "any", required = "" })
                </div>
            </div>

        </fieldset>
        <fieldset>
            <legend>材料采购系数</legend>
            <div class="form-group">
                @Html.LabelFor(m => m.PrjExtent.MaterialPurchaseRatio, new { @class = "col-lg-2 control-label text-info" })
                <div class="col-lg-10">
                    @Html.TextBoxFor(m => m.PrjExtent.MaterialPurchaseRatio, new { @class = "form-control", placeholder = "材料采购系数", type = "number", step = "any", required = "" })
                </div>
            </div>
        </fieldset>
        <br />

        <div class="form-group">
            <div class="row">
                <div class="col-lg-offset-9 col-lg-3">
                    <div class="pull-right">
                        <input type="submit" id="submit" class="btn  btn-primary" value="下一步" />&nbsp;
                        <a class="btn btn-danger" href="#">取 消</a>&nbsp;
                    </div>
                   
                    
                </div>
            </div>

        </div>
    }
</div>
